package com.baseweb.webadmin.core.model.mapper;

import com.baseweb.webadmin.core.model.bvo.ByUserTrolleyBvo;
import com.baseweb.webadmin.core.model.pojo.ByUserTrolley;
import com.baseweb.webadmin.core.model.pojo.ByUserTrolleyExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface ByUserTrolleyMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    int countByExample(ByUserTrolleyExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    int deleteByExample(ByUserTrolleyExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    @Delete({
        "delete from by_user_trolley",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    @Insert({
        "insert into by_user_trolley (user_id, product_id, ",
        "create_time, ",
        "update_time, ",
        "schedule_date, ",
        "dinner_type, biz_user_id, ",
        "amount, descn)",
        "values (#{userId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{scheduleDate,jdbcType=DATE,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2DateTypeHandler}, ",
        "#{dinnerType,jdbcType=VARCHAR}, #{bizUserId,jdbcType=INTEGER}, ",
        "#{amount,jdbcType=INTEGER}, #{descn,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(ByUserTrolley record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    int insertSelective(ByUserTrolley record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    List<ByUserTrolley> selectByExample(ByUserTrolleyExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    @Select({
        "select",
        "id, user_id, product_id, create_time, update_time, schedule_date, dinner_type, ",
        "biz_user_id, amount, descn",
        "from by_user_trolley",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    ByUserTrolley selectByPrimaryKey(Integer id);

    @Select({
            "select * from by_user_trolley a ",
            "join by_user_biz_product b on a.product_id = b.id ",
            "join `user` c on c.id = b.user_id ",
            "where a.user_id = #{userId,jdbcType=INTEGER}"
    })
    @ResultMap("TrolleyUnion")
    List<ByUserTrolleyBvo> selectByUserTrolleyList(Integer userId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    int updateByExampleSelective(@Param("record") ByUserTrolley record, @Param("example") ByUserTrolleyExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    int updateByExample(@Param("record") ByUserTrolley record, @Param("example") ByUserTrolleyExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    int updateByPrimaryKeySelective(ByUserTrolley record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_trolley
     *
     * @mbggenerated Mon Apr 24 13:56:32 CST 2017
     */
    @Update({
        "update by_user_trolley",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "product_id = #{productId,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "schedule_date = #{scheduleDate,jdbcType=DATE,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2DateTypeHandler},",
          "dinner_type = #{dinnerType,jdbcType=VARCHAR},",
          "biz_user_id = #{bizUserId,jdbcType=INTEGER},",
          "amount = #{amount,jdbcType=INTEGER},",
          "descn = #{descn,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ByUserTrolley record);
}